#include<stdio.h>
#include<math.h>
int main()
{
	float solut(float a,float b,float c,float d);
	float a,b,c,d,x;
	printf("input a,b,c,d:");
	scanf("%f%f%f%f",&a,&b,&c,&d);
	x=solut(a,b,c,d);
	printf("the root of equation is x=%5.2f\n",x);
	return 0;
}

float solut(float a,float b,float c,float d)
{
	float x1=1,x0,f,f1;
	do
	{
		x0=x1;
		f=a*x0*x0*x0+b*x0*x0+c*x0+d;
		f1=3*a*x0*x0+2*b*x0+c;
		x1=x0-f/f1;
	}
	while(fabs(x1-x0)>=1e-3);
	return x1;
}
